using System;
using System.Text;
using System.Web;
namespace tenpay
{
	public class PayRequestHandler : RequestHandler
	{
		public PayRequestHandler(HttpContext httpContext) : base(httpContext)
		{
			base.setGateUrl("http://service.tenpay.com/cgi-bin/v3.0/payservice.cgi");
		}
		public override void init()
		{
			base.setParameter("cmdno", "1");
			base.setParameter("date", DateTime.Now.ToString("yyyyMMdd"));
			base.setParameter("bargainor_id", "");
			base.setParameter("transaction_id", "");
			base.setParameter("sp_billno", "");
			base.setParameter("total_fee", "");
			base.setParameter("fee_type", "1");
			base.setParameter("return_url", "");
			base.setParameter("attach", "");
			base.setParameter("spbill_create_ip", "");
			base.setParameter("desc", "");
			base.setParameter("bank_type", "0");
			base.setParameter("cs", "gb2312");
			base.setParameter("sign", "");
		}
		protected override void createSign()
		{
			string parameter = base.getParameter("cmdno");
			string parameter2 = base.getParameter("date");
			string parameter3 = base.getParameter("bargainor_id");
			string parameter4 = base.getParameter("transaction_id");
			string parameter5 = base.getParameter("sp_billno");
			string parameter6 = base.getParameter("total_fee");
			string parameter7 = base.getParameter("fee_type");
			string parameter8 = base.getParameter("return_url");
			string parameter9 = base.getParameter("attach");
			string parameter10 = base.getParameter("spbill_create_ip");
			string parameter11 = base.getParameter("key");
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("cmdno=" + parameter + "&");
			stringBuilder.Append("date=" + parameter2 + "&");
			stringBuilder.Append("bargainor_id=" + parameter3 + "&");
			stringBuilder.Append("transaction_id=" + parameter4 + "&");
			stringBuilder.Append("sp_billno=" + parameter5 + "&");
			stringBuilder.Append("total_fee=" + parameter6 + "&");
			stringBuilder.Append("fee_type=" + parameter7 + "&");
			stringBuilder.Append("return_url=" + parameter8 + "&");
			stringBuilder.Append("attach=" + parameter9 + "&");
			if (!"".Equals(parameter10))
			{
				stringBuilder.Append("spbill_create_ip=" + parameter10 + "&");
			}
			stringBuilder.Append("key=" + base.getKey());
			string mD = MD55Util.GetMD5(stringBuilder.ToString(), this.getCharset());
			base.setParameter("sign", mD);
			base.setDebugInfo(stringBuilder.ToString() + " => sign:" + mD);
		}
	}
}
